package edu.cmu.cs211.pg.internal;

import java.util.HashSet;

import org.junit.Test;

import edu.cmu.cs211.pg.algorithms.Kruskal;
import edu.cmu.cs211.pg.graph.MyDirectedGraph;
import edu.cmu.cs211.pg.graph.WeightedEdge;

public class KruskalTest {
	
	/*
	 * creates a graph containing cycles and tests kruskal using it
	 */
	@Test
	public void CycleTest() {
		HashSet<Integer> hs = new HashSet<Integer>();
		HashSet<WeightedEdge<Integer>> edges = new HashSet<WeightedEdge<Integer>>();
		
		hs.add(0);
		hs.add(1);
		hs.add(2);
		hs.add(3);
		
		WeightedEdge we = new WeightedEdge(0,1,1);
		WeightedEdge we2 = new WeightedEdge(1,2,1);
		WeightedEdge we3 = new WeightedEdge(2,3,1);
		WeightedEdge we4 = new WeightedEdge(3,0,1);
		
		edges.add(we);
		edges.add(we2);
		edges.add(we3);
		edges.add(we4);
		
		MyDirectedGraph<Integer, WeightedEdge<Integer>> g = new MyDirectedGraph(hs, edges);
		Kruskal k = new Kruskal();
		k.spanningTree(g);
	}
	
	/*
	 * small basic graph test for kruskal
	 */
	@Test
	public void basicTest() {
		HashSet<Integer> hs = new HashSet<Integer>();
		hs.add(0);
		hs.add(1);
		hs.add(2);
		hs.add(3);
		hs.add(4);
		
		HashSet<WeightedEdge<Integer>> edges = new HashSet<WeightedEdge<Integer>>();
		WeightedEdge we = new WeightedEdge(0,1,1);
		WeightedEdge we2 = new WeightedEdge(1,2,1);
		WeightedEdge we3 = new WeightedEdge(2,3,1);
		WeightedEdge we4 = new WeightedEdge(3,4,1);
		edges.add(we);
		edges.add(we2);
		edges.add(we3);
		edges.add(we4);
		
		MyDirectedGraph<Integer, WeightedEdge<Integer>> g = new MyDirectedGraph(hs, edges);
		
		Kruskal k = new Kruskal();
		k.spanningTree(g);
		
	}
}
